package com.shxy.rlzy.mapper;

import com.shxy.rlzy.entity.Salary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tanhao
 * @since 2022-02-16
 */
public interface SalaryMapper extends BaseMapper<Salary> {
    /**
     * 条件查询员工工资信息列表-关联查询
     * @param departId
     * @param name
     * @param phone
     * @return
     */
    List<Salary> queryList(Long departId, String name, String phone);

    /**
     * 条件查询员工工资信息列表
     * @param departId
     * @param name
     * @param phone
     * @return
     */
    List<Salary> getList(Long departId, String name, String phone);

    /**
     * 获取没有工资信息的员工列表
     * @return
     */
    @Select("SELECT id FROM emp_info WHERE id NOT IN(SELECT employee_id FROM emp_salary)")
    List<Integer> getEmpIdsNotInSalary();

    /**
     * 根据身份证查询员工工资信息
     * @param idCard
     * @return
     */
    @Select("SELECT es.* FROM emp_salary AS es LEFT JOIN emp_info AS ei ON es.employee_id=ei.id WHERE ei.id_card=#{idCard}")
    Salary getByIdCard(String idCard);
}
